Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FUSE] Fix C# completion in empty explicit expression blocks #11282

Merged

Conversation

davidwengier
Copy link
Member

Fixes #11280

Commit at a time is recommended, since the fix itself is really very simple, and the last commit is updating all of the baselines.

@davidwengier davidwengier requested review from a team as code owners December 9, 2024 06:14
Copy link
Member

@jjonescz jjonescz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just curious about our behavior around line pragmas on whitespace (if there is something to fix there, I'm fine with just creating an issue)

@@ -53,6 +53,14 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.
#line hidden
#nullable disable
);
#nullable restore
#line (3,23)-(4,1) "x:\dir\subdir\Test\TestComponent.cshtml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we avoid emitting #line pragmas for whitespace nodes? (We only need source mappings right?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let @chsienki comment on this, because he recently made it so that line pragmas and source mappings were 1:1 in runtime. Obviously at that point whitespace wouldn't have been part of it, but I'm not sure which priority wins.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original assumption here was that at some point in the future, we may not have any source mappings: if we're getting the docs from the generator, we might not have the back channel for the mappings.

I think with the current architecture that's actually not going to be true, but I do think its a good idea to maintain a 1-1 mapping, so the source doc contains all the information (especially for some of our strategic partners who are using the line pragmas only)

var content = codeDocument.Source.Text.GetSubText(new TextSpan(sourceMapping.OriginalSpan.AbsoluteIndex, sourceMapping.OriginalSpan.Length)).ToString();
if (string.IsNullOrWhiteSpace(content))
{
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems there are sometimes #line pragmas emitted for whitespace. Presumably that doesn't happen always so we need to skip the validation - is there a reason it happens sometimes and not always?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was thus: The existing design time code-gen sometimes doesn't emit line pragmas, but none of the existing tests happened to cover that scenario. I decided to update the test validation here (it now matches the runtime validation, just below this change) rather that updating design time to emit line pragmas for whitespace (which runtime does) largely because updating design time code gen seems quite redundant at this point.

Could be overruled by an actual compiler team member, or maybe runtime shouldn't emit line pragmas either (see my reply to your other comment though), but I don't really have an opinion about which is best.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand

I decided to update the test validation here (it now matches the runtime validation, just below this change)

Because AFICT the only change is to skip the whitespace checks.

My assumption is this wasn't failing because none of the previous tests hit it, but the test you added does now cause this validation to fail, unless you skip the whitespace?

I'm fine with this change, but we also have an escape hatch to just not run verification on design time if it's preferred to do that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's what I meant. I updated the validation done by tests, to skip validating line pragmas on whitespace.

@jjonescz jjonescz added the area-compiler Umbrella for all compiler issues label Dec 9, 2024
Copy link
Member

@chsienki chsienki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@davidwengier davidwengier merged commit 7580777 into dotnet:main Dec 9, 2024
12 checks passed
@davidwengier davidwengier deleted the ExplicitStatementCompletionFUSE branch December 9, 2024 22:04
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-compiler Umbrella for all compiler issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FUSE] No completion in an explicit expression that has no C# Code
4 participants